<?php
	$validationName = 0;
	$validationPassword = 0;
	$validationEmail = 0;
	$validationTeam = 0;
	
	$managerNameExists = 0;
	$managerEmailExists = 0;
	$teamNameExists = 0;
	
	$manager = new Manager("", "", "");
	$team = new Team("");
	
	if(isset($_POST['addmanager'])){
		$manager = new Manager($_POST['managername'], $_POST['password'], $_POST['email']);
		$team = new Team($_POST['team']);
		
		$validationName = $manager->validationName(trim($_POST['managername']));
		$validationPassword = $manager->validationPassword(trim($_POST['password']));
		$validationEmail = $manager->validationEmail(trim($_POST['email']));
		$validationTeam = $team->validationTeamName(trim($_POST['team']));
		
		$dbconnect = DBconnect::getInstance();

		$managerNameExists = $dbconnect->isManagerNameExists($manager);
		$managerEmailExists = $dbconnect->isManagerEmailExists($manager);
		$teamNameExists = $dbconnect->isTeamNameExists($team);
	}
	
	
	if(isset($_POST['addmanager']) && ($validationName + $validationPassword + $validationEmail + $validationTeam ) == 0)
			{
				if($managerNameExists + $managerEmailExists + $teamNameExists == 0){
					$dbconnect->add_manager($manager, $team);
					$dbconnect->add_team($manager, $team);
					echo "Successfully added!";
				}
			}
?>